/*
*作者---杨彬
*
*/
<template>
    <div>
      <div class="manage-content" v-if='thisGetData'>
           <div class="manage-item-warp" @click="backProductDetail(vitem.id)"
                v-for="(vitem,vindex) in thisGetData">
              <div class="manage-item">
                <div class="radio-warp">
                  <input type="radio" name="address" :checked="vitem.isDefault==1">
                  <img class="notCheck" src="../../assets/address/notCheck.png">
                  <img class="checked" src="../../assets/address/checked.png">
                </div>
                <span class="isDefault-text" v-if="vitem.isDefault" v-text="sData.address.manage.isDefaultText"></span>
                <div class="item-content">
                  <p class="detail-address"><span
                    class="province" v-text="vitem.provinceName"></span><span
                    class="city" v-text="vitem.cityName"></span><span
                    class="district" v-text="vitem.districtName"></span><span
                    class="village" v-text="vitem.detailAddress"></span><span
                    class="number" v-text="vitem.number"></span></p>
                  <p class="person-message"><span
                    class="name" v-text="vitem.consignee"></span><span
                    class="tel" v-text="vitem.phone"></span></p>
                  <div class="item-type-warp"><span class="item-tags" v-text="vitem.label"></span></div>
                </div>
                <div class="add-minus-operation"><span
                  class="operation-item-warp" @click.stop="addressOperation(false,vitem.id,vindex)"><img src="../../assets/address/delete.png"><span v-text="sData.address.manage.delete"></span></span><span
                  class="operation-item-warp" @click.stop="addressOperation(true,vitem.id,vindex)"><img src="../../assets/address/edit.png"><span v-text="sData.address.manage.edit"></span></span></div>
              </div>
           </div>
      </div>
      <footer class="address-manage-foot" v-text="sData.address.manage.submitText" @click="addressOperation(true,'','true')"></footer>
    </div>
</template>
<script type="text/javascript">
  export default {
    data(){
      return {
        thisGetData: '',
      }
    },
    props: ["sData"],
    methods: {
      deleteAddress(oid, pindex){
        this.postAjax(this.sData.url.addressDelete, {id: oid,userId:this.sData.userId}, (res)=> {
          console.log(res);
          this.thisGetData.splice(pindex, 1);
        })
      },
      addressOperation(obool, oitemId, oindex){
        if(this.$route.params.changeCheck==='false'){
          if (obool == false) {
            this.deleteAddress(oitemId, oindex)
          }
          else {
            this.$router.replace({name:'addressAdd',params:{index:oindex}})
          }
        }
        else {
          if (obool == false) {
            this.deleteAddress(oitemId, oindex)
          }
          else {
            this.$router.replace({name:'addressAdd',params:{index:oindex,goDetail:true}})
          }
        }
        
      },
      getData(){
        this.getAjax(this.sData.url.addressManage,
          {userId: this.sData.userId, isDefault: '',receiveId:''}, (res)=> {
            this.thisGetData = res.data;
            
          })
      },
      backProductDetail(oid){
        if(this.$route.params.changeCheck==='false'){
              return;
        }
        else {
          m$.localStrages.set('addressId',oid);
          this.$router.replace({name:'sureOrder'});
        }
      }
    },
    created(){
    
      document.title = this.sData.address.manage.title;
      this.getData();

    }
  }
</script>
<style scoped lang="less">
    @import "addressManage";
</style>
